﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Order.MicroService.Api.Controllers
{
    /// <summary>
    /// Consul健康检查
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class HealthController : ControllerBase
    {
        private IConfiguration _iConfiguration;

        public HealthController(IConfiguration configuration)
        {
            this._iConfiguration = configuration;
        }

        [HttpGet]
        [Route("Index")]
        public IActionResult Index()
        {
            Console.WriteLine($"This is HealController  {this._iConfiguration["port"]} Invoke,{DateTime.Now}");
            return Ok();
        }

        [HttpGet]
        [Route("GetInfo")]
        public string GetInfo()
        {
            string ip = _iConfiguration["ip"].ToString();
            string port = _iConfiguration["port"].ToString();
            return $"此时请求的IP是：{ip},端口是：{port}";
        }
    }
}
